package com.zx.sercurity;

import android.content.Context;
import android.telephony.TelephonyManager;

public class SimRisk implements RiskControlInterface<RiskResult.NoSIMRiskResult>{
    @Override
    public RiskResult.NoSIMRiskResult riskCheck(Context context) {
        return isSimCardAvailable(context) ? new RiskResult.NoSIMRiskResult(false) : new RiskResult.NoSIMRiskResult(true);
    }

    /**
     * 校验SIM卡是否安装
     * @param context
     * @return
     */
    public boolean isSimCardAvailable(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager != null && telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY;
    }
}
